<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>跑马灯</title>
    <script src="../js/vue.js"></script>
</head>
<body>
    <div id="app">
        <button @click="start">开始</button>
        <button @click="stop">结束</button>
        <p>{{msg}}</p>
    </div>
</body>
<script>
    let vm = new Vue({
        el:"#app",
        data:{
            msg:"我命由我不由天！！！",
            clearID:null
        },
        methods:{
            start(){
                clearInterval(this.clearID)
                this.clearID = setInterval(()=>{
                    let fast = this.msg.substring(0,1)
                    let end = this.msg.substring(1)
                    this.msg = end + fast
                },500)

            },
            stop(){
                clearInterval(this.clearID)
            }
        }
    })
</script>
</html>